<template>
	<view class="index">
		<view class="title-wrapper">
			<view class="title">
				<text class="date">{{ tradeDate }}</text>
				<text class="tip">{{ dateInfo }}</text>
			</view>
			<view class="total">
				退款汇总：{{ tradeAmount }}元
			</view>
		</view>
		<view class="item" v-for="(item,index) in list" :key="index" @click="goAfterSales(item)">
			<view class="date-wrapper">
				<view class="date">{{ index+1 }}、{{ item.refundTime.substring(5) }}</view>
				<text class="btn">查看售后</text>
				<uni-icons type="right" size="16" color="#999999"></uni-icons>
			</view>
			<view class="product-name">
				{{ item.productCode + '-' + item.productName }}
			</view>
			<view class="price-wrapper">
				<text class="price">退款：{{ parseFloat((item.amount / 100).toFixed(2)) }}元</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
				tradeAmount: 0,
				tradeDate: '',
				dateInfo: ''
			}
		},
		onLoad(option) {
			this.tradeDate = option.date.substring(0, 10);
			this.tradeAmount = option.amount;
			this.dateInfo = option.dateInfo;
			this.getList(option.id)
		},
		methods: {
			async getList(id) {
				const data = await this.$api.post('/app/settlement-ledger/getSupplierRefundDetail', {
					id: id
				})
				if (data.code === 200) {
					this.list = data.data
				}
			},
			goAfterSales(item) {
				uni.navigateTo({
					url: '/subPage_afterSale/detail?id=' + item.afterSalesId
				})
			}
		},
		components: {

		}
	}
</script>

<style lang="scss" scoped>
	.index {
		height: 100%;
		overflow: auto;

		.title-wrapper {
			padding: 20rpx 30rpx;
			background-color: #FFFFFF;
			margin-top: 2rpx;

			.title {
				display: flex;
				align-items: center;

				.date {
					font-size: 32rpx;
					color: #333333;
				}

				.tip {
					margin-left: 50rpx;
					font-size: 24rpx;
					color: #777777;
				}
			}

			.total {
				margin-top: 10rpx;
				font-size: 32rpx;
				color: #333333;
			}
		}

		.item {
			background-color: #FFFFFF;
			margin-top: 2rpx;
			padding: 20rpx 30rpx;
			font-size: 30rpx;

			.date-wrapper {
				display: flex;
				align-items: center;

				.date {
					flex: 1;
				}
			}

			.product-name {
				font-size: 28rpx;
				color: #333333;
				overflow: hidden;
				text-overflow: ellipsis;
				display: -webkit-box;
				-webkit-line-clamp: 1;
				-webkit-box-orient: vertical;
				margin-top: 10rpx;
			}

			.price-wrapper {
				display: flex;
				justify-content: space-between;
				align-items: center;
				margin-top: 10rpx;

				.price {
					font-size: 32rpx;
					color: #333333;
					font-weight: bold;
				}

				.date {
					font-size: 26rpx;
					color: #777777;
				}
			}
		}
	}
</style>